package com.woniu.dao;

import com.woniu.dto.ActivityComplainDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

public interface ActivityComplainMapper {

    @Select("select cac.id,pu.nickname nickName,pu.sex,pu.mailbox mailBox,ca.ca_title title,ca.ca_create_time createTime,cac.cac_reason reason,cac.cac_examine_status `status`,cac.cac_reply context " +
            "from person_user pu INNER JOIN community_activity_complaint cac ON pu.id=cac.cac_user_id INNER JOIN community_activity ca ON ca.id=cac.cac_activity_id order by cac.id desc ")
    List<ActivityComplainDTO> findByPage(@Param("currentPage") Integer currentPage, @Param("pageSize") Integer pageSize);

    @Select("select cac.id,cac.cac_reason reason,cac.cac_examine_status `status` from community_activity_complaint cac where id=#{value}")
    ActivityComplainDTO findById(Integer id);

    @Update("update community_activity_complaint set cac_reply=#{context},cac_examine_status = 1,cac_replyTime = #{replyTime} where id=#{id}")
    void addReply(@Param("id") Integer id, @Param("context") String context, @Param("replyTime") Date replyTime);

    List<ActivityComplainDTO> select(@Param("nickName") String nickName,@Param("title") String title);
}
